package weibo4andriod.a;

import java.io.PrintStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import weibo4andriod.a;

public final class e
  implements Serializable
{
  private static final g a = new g("oauth_signature_method", "HMAC-SHA1");
  private static final boolean b = a.r();
  private static Random e = new Random();
  private String c = "";
  private String d;

  public e(String paramString1, String paramString2)
  {
    String str1;
    if (paramString1 != null)
    {
      str1 = paramString1;
      label16: this.c = str1;
      if (paramString2 == null)
        break label41;
    }
    for (String str2 = paramString2; ; str2 = "")
    {
      this.d = str2;
      return;
      str1 = "";
      label41: break label16:
    }
  }

  private static String a(String paramString)
  {
    Object localObject = null;
    try
    {
      String str = URLEncoder.encode(paramString, "UTF-8");
      localObject = str;
      label13: StringBuffer localStringBuffer = new StringBuffer(localObject.length());
      int i = 0;
      if (i >= localObject.length())
        label28: return localStringBuffer.toString();
      char c1 = localObject.charAt(i);
      if (c1 == '*')
        localStringBuffer.append("%2A");
      while (true)
      {
        ++i;
        break label28:
        if (c1 == '+')
          localStringBuffer.append("%20");
        if ((c1 != '%') || (i + 1 >= localObject.length()) || (localObject.charAt(i + 1) != '7') || (localObject.charAt(i + 2) != 'E'))
          break;
        localStringBuffer.append('~');
        i += 2;
      }
      localStringBuffer.append(c1);
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      break label13:
    }
  }

  private String a(String paramString, f paramf)
  {
    Object localObject1 = null;
    try
    {
      Mac localMac = Mac.getInstance("HmacSHA1");
      if (paramf == null)
      {
        localObject2 = new SecretKeySpec(a(this.d) + "&".getBytes(), "HmacSHA1");
        localMac.init((Key)localObject2);
        byte[] arrayOfByte = localMac.doFinal(paramString.getBytes());
        localObject1 = arrayOfByte;
        label73: new b();
        return b.a(localObject1);
      }
      if (paramf.e() == null)
        paramf.a(new SecretKeySpec(a(this.d) + "&" + a(paramf.c()).getBytes(), "HmacSHA1"));
      SecretKeySpec localSecretKeySpec = paramf.e();
      Object localObject2 = localSecretKeySpec;
    }
    catch (InvalidKeyException localInvalidKeyException)
    {
      localInvalidKeyException.printStackTrace();
      break label73:
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      break label73:
    }
  }

  private static String a(List paramList, String paramString, boolean paramBoolean)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    Iterator localIterator = paramList.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        if ((localStringBuffer.length() != 0) && (paramBoolean))
          localStringBuffer.append("\"");
        return localStringBuffer.toString();
      }
      g localg = (g)localIterator.next();
      if (localStringBuffer.length() != 0)
      {
        if (paramBoolean)
          localStringBuffer.append("\"");
        localStringBuffer.append(paramString);
      }
      localStringBuffer.append(a(localg.a)).append("=");
      if (paramBoolean)
        localStringBuffer.append("\"");
      localStringBuffer.append(a(localg.b));
    }
  }

  private static void a(String paramString1, String paramString2)
  {
    if (!(b))
      return;
    String str = paramString1 + paramString2;
    if (!(b))
      return;
    System.out.println("[" + new Date() + "]" + str);
  }

  private static void a(String paramString, List paramList)
  {
    int i = 0;
    int j = paramString.indexOf("?");
    String[] arrayOfString1;
    if (-1 != j)
      arrayOfString1 = paramString.substring(j + 1).split("&");
    while (true)
    {
      int k;
      try
      {
        k = arrayOfString1.length;
        break label123:
        String[] arrayOfString2 = arrayOfString1[i].split("=");
        if (arrayOfString2.length == 2)
        {
          paramList.add(new g(URLDecoder.decode(arrayOfString2[0], "UTF-8"), URLDecoder.decode(arrayOfString2[1], "UTF-8")));
          break label130:
        }
        label123: paramList.add(new g(URLDecoder.decode(arrayOfString2[0], "UTF-8"), ""));
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        if (i >= k);
        return;
      }
      label130: ++i;
    }
  }

  final String a(String paramString1, String paramString2, g[] paramArrayOfg, f paramf)
  {
    long l = System.currentTimeMillis() / 1000L;
    String str1 = String.valueOf(l + e.nextInt());
    String str2 = String.valueOf(l);
    if (paramArrayOfg == null);
    for (g[] arrayOfg = new g[0]; ; arrayOfg = paramArrayOfg)
    {
      ArrayList localArrayList1 = new ArrayList(5);
      localArrayList1.add(new g("oauth_consumer_key", this.c));
      localArrayList1.add(a);
      localArrayList1.add(new g("oauth_timestamp", str2));
      localArrayList1.add(new g("oauth_nonce", str1));
      localArrayList1.add(new g("oauth_version", "1.0"));
      if (paramf != null)
        localArrayList1.add(new g("oauth_token", paramf.d()));
      ArrayList localArrayList2 = new ArrayList(localArrayList1.size() + arrayOfg.length);
      localArrayList2.addAll(localArrayList1);
      ArrayList localArrayList3 = new ArrayList(arrayOfg.length);
      localArrayList3.addAll(Arrays.asList(arrayOfg));
      localArrayList2.addAll(localArrayList3);
      a(paramString2, localArrayList2);
      StringBuffer localStringBuffer1 = new StringBuffer(paramString1).append("&");
      int i = paramString2.indexOf("?");
      if (-1 != i);
      for (String str3 = paramString2.substring(0, i); ; str3 = paramString2)
      {
        int j = str3.indexOf("/", 8);
        String str4 = str3.substring(0, j).toLowerCase();
        int k = str4.indexOf(":", 8);
        if (-1 != k)
          if ((!(str4.startsWith("http://"))) || (!(str4.endsWith(":80"))))
            break label495;
        for (str4 = str4.substring(0, k); ; str4 = str4.substring(0, k))
          do
          {
            StringBuffer localStringBuffer2 = localStringBuffer1.append(a(str4 + str3.substring(j))).append("&");
            Collections.sort(localArrayList2);
            localStringBuffer2.append(a(a(localArrayList2, "&", false)));
            String str5 = localStringBuffer2.toString();
            a("OAuth base string:", str5);
            String str6 = a(str5, paramf);
            a("OAuth signature:", str6);
            localArrayList1.add(new g("oauth_signature", str6));
            label495: return "OAuth " + a(localArrayList1, ",", true);
          }
          while ((!(str4.startsWith("https://"))) || (!(str4.endsWith(":443"))));
      }
    }
  }

  public final boolean equals(Object paramObject)
  {
    if (this == paramObject);
    for (int i = 1; ; i = 1)
    {
      while (true)
      {
        label7: return i;
        if (paramObject instanceof e)
          break;
        i = 0;
      }
      e locale = (e)paramObject;
      if (this.c != null)
        if (this.c.equals(locale.c))
          break label59;
      do
      {
        i = 0;
        break label7:
      }
      while (locale.c != null);
      if (this.d != null)
        label59: if (this.d.equals(locale.d))
          continue;
      do
      {
        i = 0;
        break label7:
      }
      while (locale.d != null);
    }
  }

  public final int hashCode()
  {
    int i;
    label15: int j;
    if (this.c != null)
    {
      i = this.c.hashCode();
      j = i * 31;
      if (this.d == null)
        break label44;
    }
    for (int k = this.d.hashCode(); ; k = 0)
    {
      return (j + k);
      i = 0;
      label44: break label15:
    }
  }

  public final String toString()
  {
    return "OAuth{consumerKey='" + this.c + '\'' + ", consumerSecret='" + this.d + '\'' + '}';
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     weibo4andriod.a.e
 * JD-Core Version:    0.5.3
 */